package com.example.bms.user.service.impl;

import com.example.bms.user.entity.UserinfoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.utils.PageUtils;
import com.example.common.utils.Query;

import com.example.bms.user.dao.UserDao;
import com.example.bms.user.entity.UserEntity;
import com.example.bms.user.service.UserService;
import org.springframework.util.ObjectUtils;


@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<UserEntity> queryWrapper=new QueryWrapper<UserEntity>();
        String name =(String) params.get("key");


        if(!ObjectUtils.isEmpty(name)){
            queryWrapper.like("uname",name).
                    or().like("uid",name).
                    or().like("phone",name).
                    or().like("address",name);
        }


        IPage<UserEntity> page = this.page(
                new Query<UserEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }



}